import { PureComponent } from 'react';
import moment from 'moment';
import {
    Row,
    Col,
    Form,
    Input,
    Select,
    Modal,
    Cascader,
    DatePicker
} from 'antd';
const FormItem = Form.Item;
const { Option } = Select;
import { dicTextByCodePcode,dicListByPcode } from '@/utils/dictionary'


@Form.create()
class CreateForm extends PureComponent {

	constructor(props) {
	    super(props);
	    this.state = {

	    }
	}


	okHandle = () => {
		const { form,handleAdd } = this.props;

	    form.validateFields((err, fieldsValue) => {
		        if (err) return;
		        form.resetFields();

			   	if(fieldsValue.a0303) {
			   				fieldsValue.a0303 = moment(fieldsValue.a0303._d).format("YYYY-MM-DD");
			   			}
			   	if(fieldsValue.a0304) {
			   				fieldsValue.a0304 = moment(fieldsValue.a0304._d).format("YYYY-MM-DD");
			   			}
			   	if(fieldsValue.a0317) {
			   				fieldsValue.a0317 = moment(fieldsValue.a0317._d).format("YYYY-MM-DD");
			   			}
			    handleAdd(fieldsValue,'JobGradeInfo');
		});
	};


	resetButton = () => {

	};

  render() {
    const {form: {getFieldDecorator}, modalVisibleByJobGradeInfo,handleModalVisible} = this.props;

return (
    <Modal
width={800}
destroyOnClose
title="添加职级信息"
visible={modalVisibleByJobGradeInfo}
onOk={this.okHandle}
onCancel={() => handleModalVisible(false,"JobGradeInfo")}
afterClose={() => this.resetButton()}
>
<Form  layout="vertical">
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>

		    <Col md={12} sm={24}>
		      <FormItem  label="职务层次">
		          {getFieldDecorator('a0301', {
		          rules: [{ required: false, message: '请输入1-10个字符',max: 10}],
		          })(
		          <Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
		          	{dicListByPcode('AE') != undefined?dicListByPcode('AE').map((item,index) => {
		          		return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
		          	}):null}
		          </Select>
		          )}
		      </FormItem>
		    </Col>

		    <Col md={12} sm={24}>
		      <FormItem  label="状态">
		          {getFieldDecorator('a0314', {
		            rules: [{ required: false, message: '请选择'}],
		          })(
		            <Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
		            	{dicListByPcode('AE') != undefined?dicListByPcode('AE').map((item,index) => {
		            		return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
		            	}):null}
		            </Select>
		          )}
		      </FormItem>
		    </Col>

		</Row>
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>

		    <Col md={12} sm={24}>
		      <FormItem  label="起算日期">
		          {getFieldDecorator('a0304',{
		          	})(
		          	<DatePicker  format="YYYY-MM-DD" style={{ width: '100%' }} placeholder="请选择"/>,
		          	)}
		      </FormItem>
		    </Col>
		    <Col md={12} sm={24}>
		      <FormItem  label="是否高配">
		          {getFieldDecorator('a0319', {
		          rules: [{ required: false, message: '请选择'}],
		          })(
		          <Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
		          	{dicListByPcode('AE') != undefined?dicListByPcode('AE').map((item,index) => {
		          		return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
		          	}):null}
		          </Select>
		          )}
		      </FormItem>
		    </Col>

		</Row>

		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>

		<Col md={12} sm={24}>
		      <FormItem  label="变动原因">
		          {getFieldDecorator('a0318', {
		          rules: [{ required: false, message: '请选择'}],
		          })(
		          	<Select labelInValue placeholder="请选择" style={{ width: '100%' }}>
		          	  	{dicListByPcode('YT') != undefined?dicListByPcode('YT').map((item,index) => {
		          	  		return <Option value={item.DICTVALUE}>{item.DESCRIPTION}</Option>
		          	  	}):null}
		          	  </Select>
		          )}
		      </FormItem>
		    </Col>

		    <Col md={12} sm={24}>
		      <FormItem  label="批准文号">
		          {getFieldDecorator('a0311',{
		            rules: [{ required: false, message: '请选择！'}],
		          })(
		          	<Input placeholder="1-40个字符" />
		          )}
		      </FormItem>
		    </Col>

		</Row>

		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>


		    <Col md={12} sm={24}>
		      <FormItem  label="批准机关名称">
		          {getFieldDecorator('a0307_1', {
		          rules: [{ required: false, message: '请选择'}],
		          })(
		            <Input placeholder="1-40个字符" />
		          )}
		      </FormItem>
		    </Col>
		    <Col md={12} sm={24}>
		      <FormItem  label="批准机关代码">
		          {getFieldDecorator('a0307_2', {
		          rules: [{ required: false, message: '1-40个字符'}],
		          })(<Input placeholder="1-40个字符" />)}
		      </FormItem>
		    </Col>

		</Row>

		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>


		    <Col md={12} sm={24}>
		      <FormItem  label="批准日期">
		          {getFieldDecorator('a0303', {
		          rules: [{ required: false, message: '请选择' }],
		          })(<DatePicker  format="YYYY-MM-DD" style={{ width: '100%' }} placeholder="请选择"/>)}
		      </FormItem>
		    </Col>

		   	<Col  md={12} sm={24}>
		   	  <FormItem  label="终止日期">
		   	      {getFieldDecorator('a0317', {
		   	        rules: [{ required: false, message: '请选择'}],
		                })(<DatePicker  format="YYYY-MM-DD" style={{ width: '100%' }} placeholder="请选择"/>)}
		            </FormItem>
		   	</Col>

		</Row>
		<Row gutter={{ md: 8, lg: 24, xl: 48 }}>


		  <Col md={12} sm={24}>
		    <FormItem  label="职务层次备注">
		        {getFieldDecorator('a0320', {
		          rules: [{ required: false, message: '请选择'}],
		          })(
		          <Input placeholder="1-40个字符" />
		        )}
		    </FormItem>
		  </Col>
		</Row>
    	{/*<Row gutter={{ md: 8, lg: 24, xl: 48 }}>

	        <Col md={12} sm={24}>
	          <FormItem  label="是否第一学历">
	              {getFieldDecorator('first_education_type',{
	              	rules: [{ required: true,message: '请选择' }],
	              })(
	              	<Select placeholder="请选择" style={{ width: '100%' }}>
	                    <Select.Option key="1">是</Select.Option>
	                    <Select.Option key="0">否</Select.Option>
	                </Select>
	              )}
	          </FormItem>
	        </Col>

    	</Row>*/}

</Form>
</Modal>
);
  }

}

export default CreateForm;
